package com.fjwt.gz.mch.ctrl.activity;

import cn.hutool.json.JSONUtil;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.ActivityHelpDTO;
import com.fjwt.gz.db.entity.ActivityHelpEntity;
import com.fjwt.gz.db.vo.ActivityHelpVO;
import com.fjwt.gz.mch.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.ActivityHelpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发起活动助力
 *
 * @Author: Will
 * @Date: 2023-12-29
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/api/activity/help")
public class ActivityHelpController extends CommonCtrl {

    @Autowired
    private ActivityHelpService activityHelpService;

    /**
     * 发起人详情
     * @return
     */
    @PostMapping(value = "/details")
    public ApiRes details() {
        Long fansId = getCurrentUser().getFansId();
        ActivityHelpDTO dto = getObject(ActivityHelpDTO.class);
        log.info("C端发起人详情，请求地址：/api/activity/help/details，请求参数：{}", JSONUtil.toJsonStr(dto));
        dto.setFansId(fansId);
        ActivityHelpVO fActivityHelpVO = activityHelpService.details(dto);
        log.info("C端发起人详情，请求地址：/api/activity/help/details，返回结果：{}", JSONUtil.toJsonStr(fActivityHelpVO));
        return ApiRes.ok(fActivityHelpVO);
    }

    /**
     * 新增发起活动助力
     * @return
     */
    @PostMapping("/add")
    public ApiRes add() {
        ActivityHelpDTO dto = getObject(ActivityHelpDTO.class);
        log.info("C端发起人详情，请求地址：/api/activity/help/add，请求参数：{}", JSONUtil.toJsonStr(dto));
        Long fansId = getCurrentUser().getFansId();
        dto.setFansId(fansId);
        activityHelpService.saveActivityHelp(dto);
        return ApiRes.ok();
    }

}

